package com.weilai.dao;

import com.weilai.domain.Thought;
import com.weilai.domain.Videos;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ThoughtDao {
    //发布想法
    @Insert("insert into thought values (null,#{userId},#{title},#{content},#{createTime},#{updateTime})")
    void add(Thought thought);
    //删除想法
    @Delete("delete from thought where id=#{id}")
    void deleteById(int id);
    //修改想法
    @Update("update thought set title=#{title},content=#{content} where id=#{id}")
    void update(Thought thought);
    //查询别人所有想法
    @Select({"select * from thought where user_id=#{userId} order by create_time desc"})
    List<Thought> selectAllUsersThought(int userId);
    //查询自己所有想法
    @Select({"select * from thought where user_id=#{userId} order by create_time desc"})
    List<Thought> selectMyAllThought(int userId);
    //根据id查询想法
    @Select("select * from thought where id=#{id}")
    Thought selectById(int id);

    //根据UserId查询想法
    @Select("select * from thought where user_id=#{id}")
    List<Thought> selectByUserId(int userId);
    //在首页查询所有想法
    @Select("select * from thought order by create_time desc")
    List<Thought> selectAll();

    // 按 userid 删除想法
    @Delete("DELETE FROM thought WHERE user_id = #{userId}")
    void deleteUserById(int userId);
}
